#include "file_system/file_reader/block_file_reader.h"

namespace hawking {
namespace indexlib {

BlockCacheOption BlockFileReader::default_blk_opt;
AioOption BlockFileReader::default_aio_opt;

BlockFileReader::BlockFileReader(
    const std::string& filepath,
    const BlockCacheOption& blk_opt,
    const AioOption& aio_opt) : FileReader(filepath) {
    blk_opt_ = blk_opt;
    aio_opt_ = aio_opt;
    accessor_ = std::make_unique<BlockFileAccessor>(filepath);
}

Status BlockFileReader::Init() {
    return accessor_->Init(blk_opt_, aio_opt_);
}

ReturnValue<size_t> BlockFileReader::Read(uint8_t* buffer, size_t length, size_t offset) {
    return accessor_->Read(buffer, length, offset);
}

ReturnValue<size_t> BlockFileReader::BatchRead(
    const std::vector<FilePart>& batch) {
    return accessor_->Read(batch);
}

}
}
